package com.hyl.types.design.framework.tree;

import lombok.Getter;
import lombok.Setter;

/**
 * @author hyl
 * @description
 * @create 2025-06-15 15:25
 */
public abstract class AbstractStrategyRouter<T,D,R> implements StrategyHandler<T,D,R>, StrategyMapper<T,D,R> {

    @Getter
    @Setter
    private StrategyHandler<T,D,R> defaultstrategyHandler = StrategyHandler.DEFAULT;
    public R router(T requestParameter,D dynamicContext) throws Exception{
        StrategyHandler<T, D, R> strategyHandler = get(requestParameter, dynamicContext);
        if (null != strategyHandler) return strategyHandler.apply(requestParameter, dynamicContext);
        return defaultstrategyHandler.apply(requestParameter, dynamicContext);
    }

}
